﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

namespace SpaceMan.Entities.Attachments
{
    class C_ATT_StandardSpeaker : IC_ATT_Attachment
    {
        public C_ATT_StandardSpeaker(string fileName, bool loops)
        {
            SEInstance = S_Global.getSound(fileName).CreateInstance();
            AE = new AudioEmitter();
            SEInstance.IsLooped = loops;
        }
        bool loops;
        SoundEffectInstance SEInstance;
        AudioEmitter AE;
        public void SoundUpdate(float Volume, float Pitch)
        {
            AE.Position = new Vector3(Position, 0);
            SEInstance.Pitch = MathHelper.Clamp(Pitch * S_Global.TIMESCALE, -1f, 1f);
            SEInstance.Volume = Volume;
            //SEInstance.Apply3D(S_Global.GlobalListener, AE);
        }

        public void PlaySound()
        {
            SEInstance.Play();
        }
        public void StopSound()
        {
            SEInstance.Stop();
        }
    }
}
